<!DOCTYPE html>
  
  
  
  
   <html class="no-js"> 

  <head lang="en-us">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=10" />
    <title>NoNonsense FilePicker</title>
    <meta name="generator" content="Hugo 0.16" />

    
    <meta name="description" content="An extensible and flexible file-picker for Android.">
    
    <link rel="canonical" href="http://spacecowboy.github.io/NoNonsense-FilePicker/">
    
    <meta name="author" content="SpaceCowboy">
    

    <meta property="og:url" content="http://spacecowboy.github.io/NoNonsense-FilePicker/">
    <meta property="og:title" content="NoNonsense FilePicker">
    
    <meta name="apple-mobile-web-app-title" content="NoNonsense FilePicker">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

    <link rel="shortcut icon" type="image/x-icon" href="http://spacecowboy.github.io/NoNonsense-FilePicker/images/favicon.ico">
    <link rel="icon" type="image/x-icon" href="http://spacecowboy.github.io/NoNonsense-FilePicker/images/favicon.ico">

    <style>
      @font-face {
        font-family: 'Icon';
        src: url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.eot?52m981');
        src: url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.eot?#iefix52m981')
               format('embedded-opentype'),
             url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.woff?52m981')
               format('woff'),
             url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.ttf?52m981')
               format('truetype'),
             url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.svg?52m981#icon')
               format('svg');
        font-weight: normal;
        font-style: normal;
      }
    </style>

    <link rel="stylesheet" href="http://spacecowboy.github.io/NoNonsense-FilePicker/stylesheets/application.css">
    <link rel="stylesheet" href="http://spacecowboy.github.io/NoNonsense-FilePicker/stylesheets/temporary.css">
    <link rel="stylesheet" href="http://spacecowboy.github.io/NoNonsense-FilePicker/stylesheets/palettes.css">
    <link rel="stylesheet" href="http://spacecowboy.github.io/NoNonsense-FilePicker/stylesheets/highlight/highlight.css">

    
    
    
    <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:400,700|Roboto%2bMono">
    <style>
      body, input {
        font-family: 'Roboto', Helvetica, Arial, sans-serif;
      }
      pre, code {
        font-family: 'Roboto Mono', 'Courier New', 'Courier', monospace;
      }
    </style>

    
    <script src="http://spacecowboy.github.io/NoNonsense-FilePicker/javascripts/modernizr.js"></script>

    
    <link href="http://spacecowboy.github.io/NoNonsense-FilePicker/index.xml" rel="alternate" type="application/rss+xml" title="NoNonsense FilePicker" />
    <link href="http://spacecowboy.github.io/NoNonsense-FilePicker/index.xml" rel="feed" type="application/rss+xml" title="NoNonsense FilePicker" />
    

  </head>
  <body class="palette-primary-red palette-accent-light green">



	
	


<div class="backdrop">
	<div class="backdrop-paper"></div>
</div>

<input class="toggle" type="checkbox" id="toggle-drawer">
<input class="toggle" type="checkbox" id="toggle-search">
<label class="toggle-button overlay" for="toggle-drawer"></label>

<header class="header">
	<nav aria-label="Header">
  <div class="bar default">
    <div class="button button-menu" role="button" aria-label="Menu">
      <label class="toggle-button icon icon-menu" for="toggle-drawer">
        <span></span>
      </label>
    </div>
    <div class="stretch">
      <div class="title">
        NoNonsense FilePicker
      </div>
    </div>

    

    
    <div class="button button-github" role="button" aria-label="GitHub">
      <a href="https://github.com/spacecowboy" title="@spacecowboy on GitHub" target="_blank" class="toggle-button icon icon-github"></a>
    </div>
    
    
        
  </div>
  <div class="bar search">
    <div class="button button-close" role="button" aria-label="Close">
      <label class="toggle-button icon icon-back" for="toggle-search"></label>
    </div>
    <div class="stretch">
      <div class="field">
        <input class="query" type="text" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck>
      </div>
    </div>
    <div class="button button-reset" role="button" aria-label="Search">
      <button class="toggle-button icon icon-close" id="reset-search"></button>
    </div>
  </div>
</nav>
</header>

<main class="main">
	<div class="drawer">
		<nav aria-label="Navigation">
  <a href="https://github.com/spacecowboy/NoNonsense-FilePicker" class="project">
    <div class="banner">
      
      <div class="name">
        <strong>NoNonsense FilePicker </strong>
        
          <br>
          spacecowboy/NoNonsense-FilePicker
        
      </div>
    </div>
  </a>

  <div class="scrollable">
    <div class="wrapper">
      
        <ul class="repo">
          <li class="repo-download">
            <a href="https://github.com/spacecowboy/NoNonsense-FilePicker/archive/master.zip" target="_blank" title="Download" data-action="download">
              <i class="icon icon-download"></i> Download
            </a>
          </li>
          <li class="repo-stars">
            <a href="https://github.com/spacecowboy/NoNonsense-FilePicker/stargazers" target="_blank" title="Stargazers" data-action="star">
              <i class="icon icon-star"></i> Stars
              <span class="count">&ndash;</span>
            </a>
          </li>
        </ul>
        <hr>
      

      <div class="toc">
        
        <ul>
          




<li>
  
    



<a  title="Readme" href="http://spacecowboy.github.io/NoNonsense-FilePicker/readme/">
	
	Readme
</a>


  
</li>



<li>
  
    



<a  title="Changelog" href="http://spacecowboy.github.io/NoNonsense-FilePicker/changelog/">
	
	Changelog
</a>


  
</li>



<li>
  
    



<a  title="License" href="http://spacecowboy.github.io/NoNonsense-FilePicker/license/">
	
	License
</a>


  
</li>



<li>
  
    <span class="section">Examples</span>
    <ul>
      
        
        



<a  title="Change the sort order" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/sortorder/">
	
	Change the sort order
</a>


      
        
        



<a  title="Filter based on file extension" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/filter_file_extension/">
	
	Filter based on file extension
</a>


      
        
        



<a  title="Custom item layout" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/custom_item_layout/">
	
	Custom item layout
</a>


      
        
        



<a  title="Override the back button" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/override_back_button/">
	
	Override the back button
</a>


      
        
        



<a  title="Override selection behavior" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/override_selection_behavior/">
	
	Override selection behavior
</a>


      
        
        



<a  title="Standalone fragment" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/standalone_fragment/">
	
	Standalone fragment
</a>


      
    </ul>
  
</li>


        </ul>
        

        
        <hr>
        <span class="section">The author</span>
        
        <ul>
          

          
          <li>
            <a href="https://github.com/spacecowboy" target="_blank" title="@spacecowboy on GitHub">
              @spacecowboy on GitHub
            </a>
          </li>
          
        </ul>
        
      </div>
    </div>
  </div>
</nav>

	</div>

	<article class="article">
		<div class="wrapper">
			
				<h1>Readme </h1>

				

<p>
<img src="http://spacecowboy.github.io/NoNonsense-FilePicker/screenshots/Nexus6-picker-dark.png" width="25%"/>

<img src="http://spacecowboy.github.io/NoNonsense-FilePicker/screenshots/Nexus10-picker-light.png" width="60%"/>
</p>

<ul>
<li>Extendable for sources other than SD-card (Dropbox, FTP, Drive, etc)</li>
<li>Can select multiple items</li>
<li>Select directories or files, or both</li>
<li>Create new directories in the picker</li>
<li>Material theme with AppCompat</li>
</ul>

<h2 id="yet-another-file-picker-library">Yet another file picker library?</h2>

<p>I needed a file picker that had two primary properties:</p>

<ol>
<li>Easy to extend: I needed a file picker that would work for normal
files on the SD-card, and also for using the Dropbox API.</li>
<li>Able to create a directory in the picker.</li>
</ol>

<p>This project has both of those qualities. As a bonus, it also scales
nicely to work on any phone or tablet. The core is placed in abstract
classes, so it is fairly easy to extend the picker to create
your own.</p>

<p>The library includes an implementation that allows the user to pick
files from the SD-card. But the picker could easily be extended to get
its file listings from another source, such as Dropbox, FTP, SSH and
so on. The sample app includes implementations which browses your
Dropbox and a Linux mirror FTP-server.</p>

<p>By inheriting from an Activity, the picker is able to be rendered as
full screen on small screens and as a dialog on large screens. It does
this through the theme system, so it is very important for the
activity to use a correctly configured theme.</p>

<h2 id="how-to-include-in-your-project-with-gradle">How to include in your project (with Gradle)</h2>

<p>Just add the dependency to your <em>build.gradle</em>:</p>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span>repositories <span style="color: #666666">{</span>
    jcenter<span style="color: #666666">()</span>
<span style="color: #666666">}</span>

dependencies <span style="color: #666666">{</span>
    compile <span style="color: #4070a0">&#39;com.nononsenseapps:filepicker:3.0.0&#39;</span>
<span style="color: #666666">}</span>
</pre></div>

<h2 id="how-to-use-the-included-sd-card-picker">How to use the included SD-card picker:</h2>

<h3 id="include-permission-in-your-manifest">Include permission in your manifest</h3>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span><span style="color: #062873; font-weight: bold">&lt;uses-permission</span> <span style="color: #4070a0">android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;</span> <span style="color: #062873; font-weight: bold">/&gt;</span>
</pre></div>

<h3 id="include-the-file-picker-activity">Include the file picker activity</h3>

<p>The intent filter is optional depending on your use case. Note that
the theme set in the manifest is important.</p>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span>    <span style="color: #062873; font-weight: bold">&lt;activity</span>
       <span style="color: #4070a0">android:name=&quot;com.nononsenseapps.filepicker.FilePickerActivity&quot;</span>
       <span style="color: #4070a0">android:label=&quot;@string/app_name&quot;</span>
       <span style="color: #4070a0">android:theme=&quot;@style/FilePickerTheme&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>
       <span style="color: #062873; font-weight: bold">&lt;intent-filter&gt;</span>
          <span style="color: #062873; font-weight: bold">&lt;action</span> <span style="color: #4070a0">android:name=&quot;android.intent.action.GET_CONTENT&quot;</span> <span style="color: #062873; font-weight: bold">/&gt;</span>
          <span style="color: #062873; font-weight: bold">&lt;category</span> <span style="color: #4070a0">android:name=&quot;android.intent.category.DEFAULT&quot;</span> <span style="color: #062873; font-weight: bold">/&gt;</span>
       <span style="color: #062873; font-weight: bold">&lt;/intent-filter&gt;</span>
    <span style="color: #062873; font-weight: bold">&lt;/activity&gt;</span>
</pre></div>

<h3 id="configure-the-theme">Configure the theme</h3>

<p>You must <strong>set the theme</strong> on the activity, but you can configure it to
match your existing application theme. You can also name it whatever
you like..</p>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span>    <span style="color: #60a0b0; font-style: italic">&lt;!-- You can also inherit from NNF_BaseTheme.Light --&gt;</span>
    <span style="color: #062873; font-weight: bold">&lt;style</span> <span style="color: #4070a0">name=&quot;FilePickerTheme&quot;</span> <span style="color: #4070a0">parent=&quot;NNF_BaseTheme&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>
        <span style="color: #60a0b0; font-style: italic">&lt;!-- Set these to match your theme --&gt;</span>
        <span style="color: #062873; font-weight: bold">&lt;item</span> <span style="color: #4070a0">name=&quot;colorPrimary&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>@color/primary<span style="color: #062873; font-weight: bold">&lt;/item&gt;</span>
        <span style="color: #062873; font-weight: bold">&lt;item</span> <span style="color: #4070a0">name=&quot;colorPrimaryDark&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>@color/primary_dark<span style="color: #062873; font-weight: bold">&lt;/item&gt;</span>
        <span style="color: #062873; font-weight: bold">&lt;item</span> <span style="color: #4070a0">name=&quot;colorAccent&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>@color/accent<span style="color: #062873; font-weight: bold">&lt;/item&gt;</span>

        <span style="color: #60a0b0; font-style: italic">&lt;!-- Need to set this also to style create folder dialog --&gt;</span>
        <span style="color: #062873; font-weight: bold">&lt;item</span> <span style="color: #4070a0">name=&quot;alertDialogTheme&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>@style/FilePickerAlertDialogTheme<span style="color: #062873; font-weight: bold">&lt;/item&gt;</span>

        <span style="color: #60a0b0; font-style: italic">&lt;!-- If you want to set a specific toolbar theme, do it here --&gt;</span>
        <span style="color: #60a0b0; font-style: italic">&lt;!-- &lt;item name=&quot;nnf_toolbarTheme&quot;&gt;@style/ThemeOverlay.AppCompat.Dark.ActionBar&lt;/item&gt; --&gt;</span>
    <span style="color: #062873; font-weight: bold">&lt;/style&gt;</span>

    <span style="color: #062873; font-weight: bold">&lt;style</span> <span style="color: #4070a0">name=&quot;FilePickerAlertDialogTheme&quot;</span> <span style="color: #4070a0">parent=&quot;Theme.AppCompat.Dialog.Alert&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>
        <span style="color: #062873; font-weight: bold">&lt;item</span> <span style="color: #4070a0">name=&quot;colorPrimary&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>@color/primary<span style="color: #062873; font-weight: bold">&lt;/item&gt;</span>
        <span style="color: #062873; font-weight: bold">&lt;item</span> <span style="color: #4070a0">name=&quot;colorPrimaryDark&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>@color/primary_dark<span style="color: #062873; font-weight: bold">&lt;/item&gt;</span>
        <span style="color: #062873; font-weight: bold">&lt;item</span> <span style="color: #4070a0">name=&quot;colorAccent&quot;</span><span style="color: #062873; font-weight: bold">&gt;</span>@color/accent<span style="color: #062873; font-weight: bold">&lt;/item&gt;</span>
    <span style="color: #062873; font-weight: bold">&lt;/style&gt;</span>
</pre></div>

<h3 id="starting-the-picker-in-your-app">Starting the picker in your app</h3>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span>    <span style="color: #60a0b0; font-style: italic">// This always works</span>
    Intent i <span style="color: #666666">=</span> <span style="color: #007020; font-weight: bold">new</span> Intent<span style="color: #666666">(</span>context<span style="color: #666666">,</span> FilePickerActivity<span style="color: #666666">.</span><span style="color: #4070a0">class</span><span style="color: #666666">);</span>
    <span style="color: #60a0b0; font-style: italic">// This works if you defined the intent filter</span>
    <span style="color: #60a0b0; font-style: italic">// Intent i = new Intent(Intent.ACTION_GET_CONTENT);</span>

    <span style="color: #60a0b0; font-style: italic">// Set these depending on your use case. These are the defaults.</span>
    i<span style="color: #666666">.</span><span style="color: #4070a0">putExtra</span><span style="color: #666666">(</span>FilePickerActivity<span style="color: #666666">.</span><span style="color: #4070a0">EXTRA_ALLOW_MULTIPLE</span><span style="color: #666666">,</span> <span style="color: #007020; font-weight: bold">false</span><span style="color: #666666">);</span>
    i<span style="color: #666666">.</span><span style="color: #4070a0">putExtra</span><span style="color: #666666">(</span>FilePickerActivity<span style="color: #666666">.</span><span style="color: #4070a0">EXTRA_ALLOW_CREATE_DIR</span><span style="color: #666666">,</span> <span style="color: #007020; font-weight: bold">false</span><span style="color: #666666">);</span>
    i<span style="color: #666666">.</span><span style="color: #4070a0">putExtra</span><span style="color: #666666">(</span>FilePickerActivity<span style="color: #666666">.</span><span style="color: #4070a0">EXTRA_MODE</span><span style="color: #666666">,</span> FilePickerActivity<span style="color: #666666">.</span><span style="color: #4070a0">MODE_FILE</span><span style="color: #666666">);</span>

    <span style="color: #60a0b0; font-style: italic">// Configure initial directory by specifying a String.</span>
    <span style="color: #60a0b0; font-style: italic">// You could specify a String like &quot;/storage/emulated/0/&quot;, but that can</span>
    <span style="color: #60a0b0; font-style: italic">// dangerous. Always use Android&#39;s API calls to get paths to the SD-card or</span>
    <span style="color: #60a0b0; font-style: italic">// internal memory.</span>
    i<span style="color: #666666">.</span><span style="color: #4070a0">putExtra</span><span style="color: #666666">(</span>FilePickerActivity<span style="color: #666666">.</span><span style="color: #4070a0">EXTRA_START_PATH</span><span style="color: #666666">,</span> Environment<span style="color: #666666">.</span><span style="color: #4070a0">getExternalStorageDirectory</span><span style="color: #666666">().</span><span style="color: #4070a0">getPath</span><span style="color: #666666">());</span>

    startActivityForResult<span style="color: #666666">(</span>i<span style="color: #666666">,</span> FILE_CODE<span style="color: #666666">);</span>
</pre></div>

<h3 id="handling-the-result">Handling the result</h3>

<p>If you have a minimum requirement of Jelly Bean (API 16) and above,
you can skip the second method.</p>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span>    <span style="color: #555555; font-weight: bold">@TargetApi</span><span style="color: #666666">(</span>Build<span style="color: #666666">.</span><span style="color: #4070a0">VERSION_CODES</span><span style="color: #666666">.</span><span style="color: #4070a0">JELLY_BEAN</span><span style="color: #666666">)</span>
    <span style="color: #555555; font-weight: bold">@Override</span>
    <span style="color: #007020; font-weight: bold">protected</span> <span style="color: #902000">void</span> <span style="color: #06287e">onActivityResult</span><span style="color: #666666">(</span><span style="color: #902000">int</span> requestCode<span style="color: #666666">,</span> <span style="color: #902000">int</span> resultCode<span style="color: #666666">,</span> Intent data<span style="color: #666666">)</span> <span style="color: #666666">{</span>
        <span style="color: #007020; font-weight: bold">if</span> <span style="color: #666666">(</span>requestCode <span style="color: #666666">==</span> FILE_CODE <span style="color: #666666">&amp;&amp;</span> resultCode <span style="color: #666666">==</span> Activity<span style="color: #666666">.</span><span style="color: #4070a0">RESULT_OK</span><span style="color: #666666">)</span> <span style="color: #666666">{</span>
            <span style="color: #007020; font-weight: bold">if</span> <span style="color: #666666">(</span>data<span style="color: #666666">.</span><span style="color: #4070a0">getBooleanExtra</span><span style="color: #666666">(</span>FilePickerActivity<span style="color: #666666">.</span><span style="color: #4070a0">EXTRA_ALLOW_MULTIPLE</span><span style="color: #666666">,</span> <span style="color: #007020; font-weight: bold">false</span><span style="color: #666666">))</span> <span style="color: #666666">{</span>
                <span style="color: #60a0b0; font-style: italic">// For JellyBean and above</span>
                <span style="color: #007020; font-weight: bold">if</span> <span style="color: #666666">(</span>Build<span style="color: #666666">.</span><span style="color: #4070a0">VERSION</span><span style="color: #666666">.</span><span style="color: #4070a0">SDK_INT</span> <span style="color: #666666">&gt;=</span> Build<span style="color: #666666">.</span><span style="color: #4070a0">VERSION_CODES</span><span style="color: #666666">.</span><span style="color: #4070a0">JELLY_BEAN</span><span style="color: #666666">)</span> <span style="color: #666666">{</span>
                    ClipData clip <span style="color: #666666">=</span> data<span style="color: #666666">.</span><span style="color: #4070a0">getClipData</span><span style="color: #666666">();</span>

                    <span style="color: #007020; font-weight: bold">if</span> <span style="color: #666666">(</span>clip <span style="color: #666666">!=</span> <span style="color: #007020; font-weight: bold">null</span><span style="color: #666666">)</span> <span style="color: #666666">{</span>
                        <span style="color: #007020; font-weight: bold">for</span> <span style="color: #666666">(</span><span style="color: #902000">int</span> i <span style="color: #666666">=</span> <span style="color: #40a070">0</span><span style="color: #666666">;</span> i <span style="color: #666666">&lt;</span> clip<span style="color: #666666">.</span><span style="color: #4070a0">getItemCount</span><span style="color: #666666">();</span> i<span style="color: #666666">++)</span> <span style="color: #666666">{</span>
                            Uri uri <span style="color: #666666">=</span> clip<span style="color: #666666">.</span><span style="color: #4070a0">getItemAt</span><span style="color: #666666">(</span>i<span style="color: #666666">).</span><span style="color: #4070a0">getUri</span><span style="color: #666666">();</span>
                            <span style="color: #60a0b0; font-style: italic">// Do something with the URI</span>
                        <span style="color: #666666">}</span>
                    <span style="color: #666666">}</span>
                <span style="color: #60a0b0; font-style: italic">// For Ice Cream Sandwich</span>
                <span style="color: #666666">}</span> <span style="color: #007020; font-weight: bold">else</span> <span style="color: #666666">{</span>
                    ArrayList<span style="color: #666666">&lt;</span>String<span style="color: #666666">&gt;</span> paths <span style="color: #666666">=</span> data<span style="color: #666666">.</span><span style="color: #4070a0">getStringArrayListExtra</span>
                                <span style="color: #666666">(</span>FilePickerActivity<span style="color: #666666">.</span><span style="color: #4070a0">EXTRA_PATHS</span><span style="color: #666666">);</span>

                    <span style="color: #007020; font-weight: bold">if</span> <span style="color: #666666">(</span>paths <span style="color: #666666">!=</span> <span style="color: #007020; font-weight: bold">null</span><span style="color: #666666">)</span> <span style="color: #666666">{</span>
                        <span style="color: #007020; font-weight: bold">for</span> <span style="color: #666666">(</span>String path<span style="color: #666666">:</span> paths<span style="color: #666666">)</span> <span style="color: #666666">{</span>
                            Uri uri <span style="color: #666666">=</span> Uri<span style="color: #666666">.</span><span style="color: #4070a0">parse</span><span style="color: #666666">(</span>path<span style="color: #666666">);</span>
                            <span style="color: #60a0b0; font-style: italic">// Do something with the URI</span>
                        <span style="color: #666666">}</span>
                    <span style="color: #666666">}</span>
                <span style="color: #666666">}</span>

            <span style="color: #666666">}</span> <span style="color: #007020; font-weight: bold">else</span> <span style="color: #666666">{</span>
                Uri uri <span style="color: #666666">=</span> data<span style="color: #666666">.</span><span style="color: #4070a0">getData</span><span style="color: #666666">();</span>
                <span style="color: #60a0b0; font-style: italic">// Do something with the URI</span>
            <span style="color: #666666">}</span>
        <span style="color: #666666">}</span>
    <span style="color: #666666">}</span>
</pre></div>

<h2 id="customizing-the-picker">Customizing the picker</h2>

<p>Extend <code>AbstractFilePickerActivity</code> and implement <code>getFragment</code>. It
should return an instance of <code>AbstractFilePickerFragment</code>. This
basically means that the activity is just the same boilerplate with as
single line changed (see the sample app&rsquo;s Dropbox example for an
activity which actually has to do some extra work):</p>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span><span style="color: #60a0b0; font-style: italic">// Making a custom SD-card picker</span>
<span style="color: #007020; font-weight: bold">public</span> <span style="color: #007020; font-weight: bold">class</span> <span style="color: #0e84b5; font-weight: bold">MyPickerActivity</span> <span style="color: #007020; font-weight: bold">extends</span> AbstractFilePickerActivity<span style="color: #666666">&lt;</span>File<span style="color: #666666">&gt;</span> <span style="color: #666666">{</span>

    <span style="color: #007020; font-weight: bold">public</span> <span style="color: #06287e">MyPickerActivity</span><span style="color: #666666">()</span> <span style="color: #666666">{</span>
        <span style="color: #007020; font-weight: bold">super</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #555555; font-weight: bold">@Override</span>
    <span style="color: #007020; font-weight: bold">protected</span> AbstractFilePickerFragment<span style="color: #666666">&lt;</span>File<span style="color: #666666">&gt;</span> <span style="color: #06287e">getFragment</span><span style="color: #666666">(</span>
            <span style="color: #007020; font-weight: bold">final</span> String startPath<span style="color: #666666">,</span> <span style="color: #007020; font-weight: bold">final</span> <span style="color: #902000">int</span> mode<span style="color: #666666">,</span> <span style="color: #007020; font-weight: bold">final</span> <span style="color: #902000">boolean</span> allowMultiple<span style="color: #666666">,</span>
            <span style="color: #007020; font-weight: bold">final</span> <span style="color: #902000">boolean</span> allowCreateDir<span style="color: #666666">)</span> <span style="color: #666666">{</span>
        <span style="color: #60a0b0; font-style: italic">// Only the fragment in this line needs to be changed</span>
        AbstractFilePickerFragment<span style="color: #666666">&lt;</span>File<span style="color: #666666">&gt;</span> fragment <span style="color: #666666">=</span> <span style="color: #007020; font-weight: bold">new</span> MyPickerFragment<span style="color: #666666">();</span>
        fragment<span style="color: #666666">.</span><span style="color: #4070a0">setArgs</span><span style="color: #666666">(</span>startPath<span style="color: #666666">,</span> mode<span style="color: #666666">,</span> allowMultiple<span style="color: #666666">,</span> allowCreateDir<span style="color: #666666">);</span>
        <span style="color: #007020; font-weight: bold">return</span> fragment<span style="color: #666666">;</span>
    <span style="color: #666666">}</span>
<span style="color: #666666">}</span>
</pre></div>

<h3 id="extend-abstractfilepickerfragment">Extend AbstractFilePickerFragment</h3>

<p>Which requires you to implement</p>

<ul>
<li>onNewFolder</li>
<li>isDir</li>
<li>getParent</li>
<li>getPath</li>
<li>getFullPath</li>
<li>getName</li>
<li>getRoot</li>
<li>toUri</li>
<li>getLoader</li>
</ul>

<p>If you only want to make a custom SD-card picker, you can instead extend <code>FilePickerFragment</code>, and only override the relevant method you want to change.</p>

<p>See the sample app and the examples for some concrete code.</p>

			

			<aside class="copyright" role="note">
				
				&copy; 2016 Released under the Mozilla Public License 2.0 &ndash;
				
				Documentation built with
				<a href="https://www.gohugo.io" target="_blank">Hugo</a>
				using the
				<a href="http://github.com/digitalcraftsman/hugo-material-docs" target="_blank">Material</a> theme.
			</aside>

			<footer class="footer">
				



<nav class="pagination" aria-label="Footer">
  <div class="previous">
  </div>

  
  
  <div class="next">
      <a href="http://spacecowboy.github.io/NoNonsense-FilePicker/" title="Readme">
        <span class="direction">
          Next
        </span>
        <div class="page">
          <div class="stretch">
            <div class="title">
              Readme
            </div>
          </div>
          <div class="button button-next" role="button" aria-label="Next">
            <i class="icon icon-forward"></i>
          </div>
        </div>
      </a>
  </div>
</nav>



			</footer>
		</div>
	</article>

	<div class="results" role="status" aria-live="polite">
		<div class="scrollable">
			<div class="wrapper">
				<div class="meta"></div>
				<div class="list"></div>
			</div>
		</div>
	</div>
</main>

    <script>
    
      var base_url = 'http:\/\/spacecowboy.github.io\/NoNonsense-FilePicker\/';
      var repo_id  = 'spacecowboy\/NoNonsense-FilePicker';
    
    </script>

    <script src="http://spacecowboy.github.io/NoNonsense-FilePicker/javascripts/application.js"></script>
    

    <script>
      /* Add headers to scrollspy */
      var headers   = document.getElementsByTagName("h2");
      var scrollspy = document.getElementById('scrollspy');

      if(scrollspy) {
        if(headers.length > 0) {
          for(var i = 0; i < headers.length; i++) {
            var li = document.createElement("li");
            li.setAttribute("class", "anchor");

            var a  = document.createElement("a");
            a.setAttribute("href", "#" + headers[i].id);
            a.setAttribute("title", headers[i].innerHTML);
            a.innerHTML = headers[i].innerHTML;
            
            li.appendChild(a)
            scrollspy.appendChild(li);
          }
        } else {
          scrollspy.parentElement.removeChild(scrollspy)
        }
        

        /* Add permanent link next to the headers */
        var headers = document.querySelectorAll("h1, h2, h3, h4, h5, h6");

        for(var i = 0; i < headers.length; i++) {
            var a = document.createElement("a");
            a.setAttribute("class", "headerlink");
            a.setAttribute("href", "#" + headers[i].id);
            a.setAttribute("title", "Permanent link")
            a.innerHTML = "#";
            headers[i].appendChild(a);
        }
      }
    </script>

    

    <script src="//gohugo.io/js/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
  </body>
</html>
